# @Author   : 懒羊羊
# @File     : firstpage.py
# @Time     : 2024/12/12 11:23
from appium.webdriver.common.appiumby import AppiumBy

from pages.basepage import BasePage
from pages.first_song import FaXianPage
from pages.update_myinfo import MyInfo


class FirstPage(BasePage):
    fx = (AppiumBy.ID, 'com.kkpodcast:id/find_rb')
    my = (AppiumBy.ID, 'com.kkpodcast:id/mine_rb')
    tx = (AppiumBy.ID, 'com.kkpodcast:id/header_iv')
    name = (AppiumBy.ID, 'com.kkpodcast:id/nick_rl')
    lgout = (AppiumBy.ID, 'com.kkpodcast:id/login_out_tv')
    fh = (AppiumBy.ID, 'com.kkpodcast:id/back_iv')

    def faxian(self):
        # 点击发现
        self.getElement(self.fx).click()

        return FaXianPage(self.d).go_to_song()

    def myinfo(self):
        # 点击我的
        self.getElement(self.my).click()

        # 点击头像
        self.getElement(self.tx).click()

        # 点击昵称
        self.getElement(self.name).click()

        return MyInfo(self.d)

    def fanhui(self):
        # 点击返回按钮
        self.getElement(self.fh).click()

    def lougout(self):
        # 点击我的
        self.getElement(self.my).click()

        # 点击头像
        self.getElement(self.tx).click()

        # 点击退出登录
        self.getElement(self.lgout).click()

    def m(self):
        # 点击我的
        self.getElement(self.my).click()

    def lg(self):
        # 点击头像
        self.getElement(self.tx).click()


if __name__ == '__main__':
    from pages.loginpage import Login

    fp = Login().go_to_firstpage()
    fp.faxian()
    fp.fanhui()
    fp.lougout()
    fp.d.quit()
